<?php
/**
 * Messages helper
 */
class TF_View_Helper_Messages extends Zend_View_Helper_Abstract
{
    /**
     *
     */
    public function messages ($messages = null)
    {
        if(null === $messages || 0 == count($messages)){
            $messages = $this->view->messages;
        }
        if(null === $messages || 0 == count($messages)){
        	$fm = Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger');
            $messages = $fm->getMessages();
        }
        if ($messages) {
            $res = '';
            foreach ($messages as $message) {
                $res .= '<p class="message ' . $message['type'] . '">' . $message['message'] . '</p>';
            }
            return $res;
        } else
        	return null;
    }
}